package cn.jbolt.ai.app.entity;

import cn.jbolt.ai.app.AppType;
import cn.jbolt.ai.app.vo.AccessWebConfig;
import cn.jbolt.ai.klb.FileState;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.media.Schema;

import java.io.Serializable;
import java.util.Date;

/**
 * AI应用表
 */
@TableName("ja_ai_app") // 指定数据库表名
public class AiApp implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 公开访问
     */
    public static final int ACCESS_TYPE_PUBLIC = 1;

    /**
     * 密码访问
     */
    public static final int ACCESS_TYPE_PWD = 3;


    //内置应用ID
    public  final static Integer BUILT_IN_APP_CHAT_ID=1;

    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(name = "name", description = "应用名称")
    @TableField("name")
    private String name;

    @Schema(name = "sn", description = "sn")
    @TableField("sn")
    private String sn;

    @Schema(name = "isBuildIn", description = "是否是内置", title = "是否是内置")
    @TableField("is_build_in")
    private Boolean isBuildIn;

    @Schema(name = "briefInfo", description = "简要信息")
    @TableField("brief_info")
    private String briefInfo;

    @Schema(name = "enable", description = "是否启用", title = "是否启用")
    @TableField("enable")
    private Boolean enable;

    @Schema(name = "appType", description = "应用类型", title = "应用类型")
    @TableField("app_type")
    private String appType;



    @Schema(name = "createTime", description = "创建时间")
    @JsonFormat(locale = "zh", pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;


   //以下是非数据库字段
    @TableField(exist = false)
    private JsonNode config;

    @TableField(exist = false)
    private String appTypeName;

    @TableField(exist = false)
    private AccessWebConfig accessWebConfig;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public String getBriefInfo() {
        return briefInfo;
    }

    public void setBriefInfo(String briefInfo) {
        this.briefInfo = briefInfo;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }



    public Boolean getBuildIn() {
        return isBuildIn;
    }

    public void setBuildIn(Boolean buildIn) {
        isBuildIn = buildIn;
    }

    public JsonNode getConfig() {
        return config;
    }

    public void setConfig(JsonNode config) {
        this.config = config;
    }

    public String getAppType() {
        return appType;
    }

    public void setAppType(String appType) {
        this.appType = appType;
    }
    public String getAppTypeName() {

        return AppType.getByCode(getAppType()).getDescription();
    }
    public void setAppTypeName(String appTypeName) {
        this.appTypeName=appTypeName;
    }

    public AccessWebConfig getAccessWebConfig() {
        return accessWebConfig;
    }

    public void setAccessWebConfig(AccessWebConfig accessWebConfig) {
        this.accessWebConfig = accessWebConfig;
    }
}
